<?php
class Database{
    protected $_host="localhost";
    protected $_userhost="root";
    protected $_passhost="";
    protected $_dbname="phimsot";
    protected $_conn;
    protected $_result;
    
    public function connect()
    {
        $this->_conn=mysql_connect($this->_host,$this->_userhost,$this->_passhost);
        mysql_select_db($this->_dbname,$this->_conn);
        mysql_set_charset('utf8',$this->_conn);
    }
    public function disconnect()
    {
        if(!is_null($this->_conn))
        {
            mysql_close($this->_conn);
        }
    }
    public function query($sql)
    {
        $this->_result=mysql_query($sql);
        
    }
    public function num_rows()
    {
        if(!is_null($this->_result))
        {
            $row=mysql_num_rows($this->_result);
        }
        else
            $row=false;
        return $row;
    }
    public function fetch()
    {
        if(!is_null($this->_result))
        {
            $row=mysql_fetch_assoc($this->_result);
        }
        else
            $row=False;
        return $row;
    }
   	public function fetch2()
    {
		if(!is_null($this->_result)){
			$row=mysql_fetch_array($this->_result);
		}else{
			$row=FALSE;
		}
		return $row;
	}
}
